package com.xuetang9.fujian.net.request;

import com.xuetang9.fujian.dao.UserDao;
import com.xuetang9.fujian.model.User;
import com.xuetang9.fujian.net.server.ECQServer;
import com.xuetang9.fujian.net.server.SocketHandler;

import java.util.HashMap;

/**
 * @describe:
 * @author:fujian
 * @date:2021/6/13
 * @Version: V1.0
 * @Package: com.xuetang9.fujian.net.request
 */
@SuppressWarnings("all")
public class RegisterRequestHandler extends AbstractRequestHandler{
    private UserDao dao = new UserDao();
    @Override
    public void handleRequest(HashMap<String, Object> message, SocketHandler handler, ECQServer server) {
        User user = (User) message.get("registerUser");
        System.out.println(user);
        dao.save(user);
        HashMap<String, Object> responMessage = new HashMap<>();
        responMessage.put("handlerClass","com.xuetang9.fujian.net.reponse.RegisterResponseHandler");
        responMessage.put("success",true);
        responMessage.put("userAccount",user.getAccount());
        handler.sendMessage(responMessage);
    }
}
